import type { AddRoleParams, DeleteRoleParams, GetRoleListParams, GetUserRoleListParams } from '@/model/UserRoleBo';
import http from '@/utils/RequestUtils';

// 统一前缀
const commonUrlPrefix2 = `${import.meta.env.VITE_API_BASE_FOUNDATION}/api/perm/user`;
const commonUrlPrefix3 = `${import.meta.env.VITE_API_BASE_FOUNDATION}/api/perm/role`;

/**
 * 获取用户已分配角色列表
 * @param data {"orgCode": 100001,"userId": 200001,"current": 1,"size": 10}
 * @returns TODO
 */
export function getUserAssignRole(data: GetUserRoleListParams) {
  return http.post(`${commonUrlPrefix2}/assigned-roles`, data);
}

/**
 * 删除已分配角色
 * @param data {"ids": [1234567890, 1234567891, 1234567892]}
 * @returns TODO
 */
export function deleteUserAssignRole(data: DeleteRoleParams) {
  return http.post(`${commonUrlPrefix2}/del-assigned-role`, data);
}

/**
 * 获取角色列表
 * @param data {"ids": [1234567890, 1234567891, 1234567892]}
 * @returns TODO
 */
export function getRoleList(data: GetRoleListParams) {
  return http.post(`${commonUrlPrefix3}/list`, data);
}

/**
 * 获取角色列表
 * @param data {"ids": [1234567890, 1234567891, 1234567892]}
 * @returns TODO
 */
export function getAssignableRoleList(data: GetRoleListParams) {
  return http.post(`${commonUrlPrefix2}/assignable-roles`, data);
}

/**
 * 新增分配角色
 * @param data {"ids": [1234567890, 1234567891, 1234567892]}
 * @returns TODO
 */
export function addUserAssignRole(data: AddRoleParams) {
  return http.post(`${commonUrlPrefix2}/add-assigned-roles`, data);
}
